//
//  RXEMCompletableManager.swift
//  rxemclient
//
//  Created by yangjian on 2023/4/14.
//

import UIKit
import HyphenateChat

class RXEMObservableManager: NSObject {
    let clientObservable = RXEMClientObservable()
    let chatObservable = RXEMChatObservable()
    let groupObservable = RXEMGroupObservable()
    let chatroomObservable = RXEMChatroomObservable()
    let multiDevicesObservable = RXEMMultiDevicesObservable()
    let logObservable = RXEMLogObservable()
    
    static let share = RXEMObservableManager()
    
    @discardableResult
    private override init(){}
    
    func config(){
        EMClient.shared().add(clientObservable, delegateQueue: nil)
        EMClient.shared().addMultiDevices(delegate: multiDevicesObservable, queue: nil)
        EMClient.shared().addLog(delegate: logObservable, queue: nil)
        EMClient.shared().chatManager?.add(chatObservable, delegateQueue: nil)
        EMClient.shared().groupManager?.add(groupObservable, delegateQueue: nil)
        EMClient.shared().roomManager?.add(chatroomObservable, delegateQueue: nil)
    }
    deinit {
        EMClient.shared().removeDelegate(clientObservable)
        EMClient.shared().remove(multiDevicesObservable)
        EMClient.shared().removeLog(delegate: logObservable)
        EMClient.shared().chatManager?.remove(chatObservable)
        EMClient.shared().groupManager?.removeDelegate(groupObservable)
        EMClient.shared().roomManager?.remove(chatroomObservable)
    }
}










